/*
 * @Author: 江舟 jijiangzhou@recycloud.cn
 * @Date: 2024-03-26 16:55:33
 * @LastEditors: 江舟 jijiangzhou@recycloud.cn
 * @LastEditTime: 2024-04-17 17:46:53
 * @FilePath: \vite-project\src\apis\org\index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import http from 'utils/http';

/**
 * 查询机构树列表
 * @param data.name                组织机构名称
 * @param data.type                组织机构类型
 * @returns
 */
export const getOrgTree = (data: any) => {
    return http({
        url: '/api/organization/queryOrgTree',
        method: 'post',
        data,
    });
};

/**
 * 根据id查询机构详情
 * @param data.id                机构id
 * @returns
 */
export const getOrgTreeDetailById = (data: any) => {
    return http({
        url: '/api/organization/queryDetailOrganization',
        method: 'post',
        data,
    });
};

/**
 * 查询机构树列表(已登录且已经选择租户的用户查询组织树）
 * @param data.name                机构id
 * @returns
 */
export const queryLoginOrgTree = (data: any) => {
    return http({
        url: '/api/organization/queryLoginOrgTree',
        method: 'post',
        data,
    });
};

/**
 * 修改机构
 * @param data.id     机构ID
 * @returns
 */
export const modifyOrganization = (data: any) => {
    return http({
        url: '/api/organization/modifyOrganization',
        method: 'post',
        data,
    });
};

/**
 * 新增机构
 * @param data.id     机构ID
 * @returns
 */
export const addOrganization = (data: any) => {
    return http({
        url: '/api/organization/addOrganization',
        method: 'post',
        data,
    });
};

/**
 * 删除机构
 * @param data.id     机构ID
 * @returns
 */
export const delOrganization = (data: any) => {
    return http({
        url: '/api/organization/delOrganization',
        method: 'post',
        data,
    });
};

/**
 * 通过组织ID查询角色列表
 * @param data
 * @returns
 */
export const getRolesByOrgIdOrAppId = (data: any) => {
    return http<
        {},
        {
            recordDatas: API.RolesByOrgIdOrAppIdResponseItem[];
        }
    >({
        url: '/api/role/queryRolesByOrgIdOrAppId',
        method: 'post',
        data,
    });
};

/**
 * 查询用户列表
 * @param data
 * @returns
 */
export const getUserList = (data: any) => {
    return http<
        {},
        {
            recordDatas: [];
            totalRow: number;
        }
    >({
        url: '/api/user/pageUsers',
        method: 'post',
        data,
    });
};

/**
 * 修改用户
 * @param data
 * @returns
 */
export const modifyUser = (data: any) => {
    return http({
        url: '/api/user/modifyUser',
        method: 'post',
        data,
    });
};

/**
 * 创建用户
 * @param data
 * @returns
 */
export const addUser = (data: any) => {
    return http({
        url: '/api/user/addUser',
        method: 'post',
        data,
    });
};

/**
 * 删除用户
 * @param data
 * @returns
 */
export const delUser = (data: any) => {
    return http({
        url: '/api/user/delUser',
        method: 'post',
        data,
    });
};

/**
 * 查询用户详情
 * @param data
 * @returns
 */
export const getUserDetail = (data: any) => {
    return http<{}, API.UserDetailResponseType>({
        url: '/api/user/queryDetailUser',
        method: 'post',
        data,
    });
};

/**
 * 角色列表分页查询(租户管理员登录后可以使用)
 * @param data
 * @returns
 */
export const getRoles = (data: any) => {
    return http<
        {},
        {
            totalRow: number;
            recordDatas: [];
        }
    >({
        url: '/api/role/pageRoles',
        method: 'post',
        data,
    });
};
